package com.cn.wanxi.test;

import java.util.Scanner;

public class Water {
    public static void main(String[] args) {
        /**
         * 理解什么是水仙花数？
         * 1.三位数
         * 2.每一位的三次方相加等于当前本身
         *    abc=a^3+b^3+c^3
         *
         */
//        Scanner scanner=new Scanner(System.in);
//        System.out.println("请输入一个三位数的整数");
//        int num=scanner.nextInt();
        int time = 0;
        for (int i = 100; i < 10000; i++) {

//            拿到三位数的三次方 342
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100 % 10;
            int qian = i / 1000 % 10;
            int sum = ge * ge * ge + shi * shi * shi + bai * bai * bai + qian * qian * qian;
            if (i == sum) {
                time++;
                System.out.println("当前数：" + i + "为水仙花数");
            }
        }
        System.out.println("水仙花出现的次数" + time + " 次");
    }
}
